/*  1:   */ package org.jetbrains.jps.model.module.impl;
/*  2:   */ 
/*  3:   */

import com.intellij.util.CollectConsumer;
import com.intellij.util.Consumer;
import com.intellij.util.Processor;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.module.*;
import org.jetbrains.jps.util.JpsPathUtil;

import java.io.File;
import java.util.Collection;
import java.util.LinkedHashSet;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */
/* 14:   */
/* 15:   */
/* 16:   */
/* 17:   */
/* 18:   */
/* 19:   */
/* 20:   */ 
/* 21:   */ public abstract class JpsDependenciesRootsEnumeratorBase<E extends JpsDependenciesEnumeratorBase<?>>
/* 22:   */   implements JpsDependenciesRootsEnumerator
/* 23:   */ {
/* 24:   */   protected final JpsOrderRootType myRootType;
/* 25:   */   protected final E myDependenciesEnumerator;
/* 26:   */   
/* 27:   */   public JpsDependenciesRootsEnumeratorBase(E paramE, JpsOrderRootType paramJpsOrderRootType)
/* 28:   */   {
/* 29:39 */     this.myDependenciesEnumerator = paramE;
/* 30:40 */     this.myRootType = paramJpsOrderRootType;
/* 31:   */   }
/* 32:   */   
/* 33:   */   public Collection<String> getUrls()
/* 34:   */   {
/* 35:45 */     LinkedHashSet localLinkedHashSet = new LinkedHashSet();
/* 36:46 */     a(new CollectConsumer(localLinkedHashSet));
/* 37:47 */     return localLinkedHashSet;
/* 38:   */   }
/* 39:   */   
/* 40:   */   public Collection<File> getRoots()
/* 41:   */   {
/* 42:52 */     final LinkedHashSet localLinkedHashSet = new LinkedHashSet();
/* 43:53 */     a(new Consumer()
/* 44:   */     {
/* 45:   */       public void consume(String paramAnonymousString)
/* 46:   */       {
/* 47:56 */         localLinkedHashSet.add(JpsPathUtil.urlToFile(paramAnonymousString));
/* 48:   */       }
/* 49:58 */     });
/* 50:59 */     return localLinkedHashSet;
/* 51:   */   }
/* 52:   */   
/* 53:   */   private void a(final Consumer<String> paramConsumer)
/* 54:   */   {
/* 55:63 */     this.myDependenciesEnumerator.processDependencies(new Processor()
/* 56:   */     {
/* 57:   */       public boolean process(JpsDependencyElement paramAnonymousJpsDependencyElement)
/* 58:   */       {
/* 59:66 */         if ((paramAnonymousJpsDependencyElement instanceof JpsModuleSourceDependency))
/* 60:   */         {
/* 61:67 */           JpsDependenciesRootsEnumeratorBase.this.processModuleRootUrls(paramAnonymousJpsDependencyElement.getContainingModule(), paramAnonymousJpsDependencyElement, paramConsumer);
/* 62:   */         }
/* 63:   */         else
/* 64:   */         {
/* 65:   */           Object localObject;
/* 66:69 */           if ((paramAnonymousJpsDependencyElement instanceof JpsModuleDependency))
/* 67:   */           {
/* 68:70 */             localObject = ((JpsModuleDependency)paramAnonymousJpsDependencyElement).getModule();
/* 69:71 */             if (localObject != null) {
/* 70:72 */               JpsDependenciesRootsEnumeratorBase.this.processModuleRootUrls((JpsModule)localObject, paramAnonymousJpsDependencyElement, paramConsumer);
/* 71:   */             }
/* 72:   */           }
/* 73:75 */           else if ((paramAnonymousJpsDependencyElement instanceof JpsLibraryDependency))
/* 74:   */           {
/* 75:76 */             localObject = ((JpsLibraryDependency)paramAnonymousJpsDependencyElement).getLibrary();
/* 76:77 */             if (localObject != null) {
/* 77:78 */               JpsDependenciesRootsEnumeratorBase.this.a((JpsLibrary)localObject, paramConsumer);
/* 78:   */             }
/* 79:   */           }
/* 80:81 */           else if ((paramAnonymousJpsDependencyElement instanceof JpsSdkDependency))
/* 81:   */           {
/* 82:82 */             localObject = ((JpsSdkDependency)paramAnonymousJpsDependencyElement).resolveSdk();
/* 83:83 */             if (localObject != null) {
/* 84:84 */               JpsDependenciesRootsEnumeratorBase.this.a((JpsLibrary)localObject, paramConsumer);
/* 85:   */             }
/* 86:   */           }
/* 87:   */         }
/* 88:87 */         return true;
/* 89:   */       }
/* 90:   */     });
/* 91:   */   }
/* 92:   */   
/* 93:   */   private boolean a(JpsLibrary paramJpsLibrary, Consumer<String> paramConsumer)
/* 94:   */   {
/* 95:93 */     for (String str : paramJpsLibrary.getRootUrls(this.myRootType)) {
/* 96:94 */       paramConsumer.consume(str);
/* 97:   */     }
/* 98:96 */     return true;
/* 99:   */   }
/* :0:   */   
/* :1:   */   protected abstract boolean processModuleRootUrls(JpsModule paramJpsModule, JpsDependencyElement paramJpsDependencyElement, Consumer<String> paramConsumer);
/* :2:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.jps.model.module.impl.JpsDependenciesRootsEnumeratorBase

 * JD-Core Version:    0.7.0.1

 */